package org.example.day01;

/**
 * 第一章节1.7.7:stop()释放锁的不良后果
 */
public class MyThread9 extends Thread{
    private SynchronizedObject object;

    public MyThread9(SynchronizedObject object) {
        this.object = object;
    }

    @Override
    public void run() {
        object.printString("b","bb");
    }

    public static void main(String[] args) {
        try {
            SynchronizedObject object = new SynchronizedObject();
            MyThread9 m9 = new MyThread9(object);
            m9.start();
            Thread.sleep(500);
            m9.stop();
            System.out.println(object.getUsername() + "--" + object.getPassword()); //b--aa
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
